﻿using System;
using System.Collections.Generic;
using System.Linq;
using Informant.Contacts;

namespace Informant.Clients.DataProviders.Wpf4.InformantService
{
	public partial class Contact : IContact
	{

		public IEnumerable<IOrganization> Organizations
		{
			get { return ServiceModelOrganizations.OfType<IOrganization>(); }
			set
			{
				var organizations = value.OfType<Organization>().ToList();
				if (ServiceModelOrganizations != organizations)
				{
					ServiceModelOrganizations = organizations;
					RaisePropertyChanged("Organizations");
				}
			}
		}

		public IEnumerable<IAddress> Addresses
		{
			get { return ServiceModelAddresses.OfType<IAddress>(); }
			set
			{
				var addresses = value.OfType<Address>().ToList();
				if (ServiceModelAddresses != addresses)
				{
					ServiceModelAddresses = addresses;
					RaisePropertyChanged("Addresses");
				}
			}
		}

		public IEnumerable<IEmail> Emails
		{
			get { return ServiceModelEmails.OfType<IEmail>(); }
			set
			{
				var emails = value.OfType<Email>().ToList();
				if (ServiceModelEmails != emails)
				{
					ServiceModelEmails = emails;
					RaisePropertyChanged("Emails");
				}
			}
		}

		public IEnumerable<IPhone> Phones
		{
			get { return ServiceModelPhones.OfType<IPhone>(); }
			set
			{
				var phones = value.OfType<Phone>().ToList();
				if (ServiceModelPhones != phones)
				{
					ServiceModelPhones = phones;
					RaisePropertyChanged("Phones");
				}
			}
		}

		public IEnumerable<IGroup> Groups
		{
			get { return ServiceModelGroups.OfType<IGroup>(); }
			set
			{
				var groups = value.OfType<Group>().ToList();
				if (ServiceModelGroups != groups)
				{
					ServiceModelGroups = groups;
					RaisePropertyChanged("Groups");
				}
			}
		}
	}
}
